﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Lesson13 : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Slider slider = this.gameObject.GetComponent<Slider>();
        Debug.LogFormat("slider value:{0}", slider.value);
        slider.value = 0.5f;

        #region 监听事件的方式
        slider.onValueChanged.AddListener((value)=> {
            Debug.LogFormat("代码监听 val:{0}", value);
        });
        ////添加监听
        //slider.onValueChanged.AddListener(ChangeSlider);
        ////移除监听
        //slider.onValueChanged.RemoveListener(ChangeSlider);
        ////移除所有监听
        //slider.onValueChanged.RemoveAllListeners();
        #endregion
    }

    public void ChangeSlider(float value)
    {
        Debug.LogFormat("ChangeSlider val:{0}", value);
    }
}
